package com.gxuwz.PangGuangyao.business.action.web;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.gxuwz.PangGuangyao.business.entity.SysSchool;
import com.gxuwz.PangGuangyao.business.service.ISysSchoolService;
import com.gxuwz.core.pagination.Result;
import com.gxuwz.core.web.action.BaseAction;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

public class SysSchoolAction extends BaseAction implements Preparable, ModelDriven{
	
	 protected static final String LIST_JSP = "/WEB-INF/page/web/SysSchool_list.jsp";
	 protected static final String ADD_JSP = "/WEB-INF/page/web/SysSchool_add.jsp";
	protected static final String EDIT_JSP = "/WEB-INF/page/web/SysSchool_edit.jsp";
	
	 protected final Log logger=LogFactory.getLog(getClass());
	 private Result<SysSchool> pageResult; //分页
	private SysSchool sysSchool;
	@Autowired
	private ISysSchoolService sysSchoolService;
	
	@Override
	public Object getModel() {
		
		return sysSchool;
	}

	@Override
	public void prepare() throws Exception {
		if(null == sysSchool){
			sysSchool = new SysSchool();
			}
}
	/**
	 * 列表
	 */
	public String list()throws Exception{
		logger.info("##ysSchool列表读取...");
		pageResult = sysSchoolService.find(sysSchool, getPage(), getRow());
		setForwardView(LIST_JSP);
		return SUCCESS;
	}
	/**
	 * 添加
	 */
	public String add() throws Exception{
		sysSchoolService.add(sysSchool);
		sysSchool.setSchoolId(null);
		return list();
	}
	/**
	 * 保存修改信息
	 */
	public String update() throws Exception{
		sysSchoolService.update(sysSchool);
		sysSchool.setSchoolId(null);
		return list();
	}
	/**
	 * 删除
	 */
	public String delete() throws Exception{
		sysSchoolService.delete(sysSchool.getSchoolId());
		return list();
	}
	/**
	 * 页面跳转
	 */
	public String openList(){
		return SUCCESS;
		}
	/**
	 * 跳转到添加页面
	 */
	public String openAdd(){
		forwardView = ADD_JSP;
		return SUCCESS;
	}
	/**
	 * 跳转到修改页面
	 */
	public String openEdit(){
		sysSchool = sysSchoolService.findById(sysSchool.getSchoolId());
		forwardView = EDIT_JSP;
		return SUCCESS;
	}
	public Result<SysSchool> getPageResult() {
		return pageResult;
	}

	public void setPageResult(Result<SysSchool> pageResult) {
		this.pageResult = pageResult;
	}

	public SysSchool getSysSchool() {
		return sysSchool;
	}

	public void setSysSchool(SysSchool sysSchool) {
		this.sysSchool = sysSchool;
	}

	
}
